package org.lanyu.springainovel.novel.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.lanyu.springainovel.novel.entity.Inspiration;

import java.util.List;

/**
 * 灵感Mapper接口
 */
@Mapper
public interface InspirationMapper extends BaseMapper<Inspiration> {
    
    /**
     * 根据标签查询灵感
     * 
     * @param tags 标签
     * @return 灵感列表
     */
    @Select("SELECT * FROM inspiration WHERE tags LIKE CONCAT('%', #{tags}, '%') AND is_public = 1 ORDER BY rating DESC DESC")
    List<Inspiration> findByTags(String tags);
    
    /**
     * 根据用户ID和标签查询灵感
     * 
     * @param userId 用户ID
     * @param tags 标签
     * @return 灵感列表
     */
    @Select("SELECT * FROM inspiration WHERE user_id = #{userId} AND tags LIKE CONCAT('%', #{tags}, '%') ORDER BY rating DESC")
    List<Inspiration> findByUserIdAndTags(Long userId, String tags);
    
    /**
     * 获取热门灵感
     * 
     * @param limit 限制数量
     * @return 灵感列表
     */
    @Select("SELECT * FROM inspiration WHERE is_public = 1 ORDER BY rating DESC LIMIT #{limit}")
    List<Inspiration> findHotInspirations(int limit);
}